package com.study.sort;

import java.util.Arrays;

public class BucketSort {

	public static void bucketSort(Integer[] arrayA, int m){
		
		int[] arrayC = new int[1+m];
		
		for(int i = 0; i < arrayA.length;i++){
			arrayC[arrayA[i]] ++;
		}
		
		for(int i = 0; i < arrayC.length;){
			if(arrayC[i] > 0){
				System.out.print(" " + i);
				arrayC[i] --;
			}else {
				i ++;
			}
			
		}
	}

	public static void main(String[] args) {
		Integer[] arrayA = { 1, 6, 2, 3, 8, 5, 7, 4 };
		
		bucketSort(arrayA, 8);
	
		System.out.println("end");
	}
}
